package com.zsp.coupon.convert;

import com.zsp.coupon.constant.CouponCategory;
import com.zsp.coupon.constant.ProdcutLine;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

/**
 * 产品线枚举属性转换器
 */
@Convert
public class ProductLineConvert implements AttributeConverter<ProdcutLine,Integer> {
    @Override
    public Integer convertToDatabaseColumn(ProdcutLine prodcutLine) {
        return prodcutLine.getCode();
    }

    @Override
    public ProdcutLine convertToEntityAttribute(Integer code) {
        return ProdcutLine.of(code);
    }
}
